package com.zbkj.dal.base.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * @author 484
 */
@Getter
@AllArgsConstructor
public enum ExpressTraceOpCode {

    /**
     * 物流操作类型
     */
    _30("30", "快件[xxx营业点装车], 准备发往[xxx集散中心]", OrderInvoceStatus.TRANSIT),
    _31("31", "快件到达[xxx集散中心]", OrderInvoceStatus.TRANSIT),
    _33("33", "派件异常原因", OrderInvoceStatus.ERROR),
    _3036("3036", "快件在xxx,准备送往下一站", OrderInvoceStatus.TRANSIT),
    _44("44", "正在派送中,请您准备签收(派件人:xxx,电话:xxx)", OrderInvoceStatus.DELIVERY),
    _50("50", "顺丰已收件", OrderInvoceStatus.COLLECTED),
    _70("70", "由于xxx原因,派件不成功", OrderInvoceStatus.ERROR),
    _80("80", "已签收,感谢使用顺丰,期待再次为您服务", OrderInvoceStatus.SIGNED),
    _8000("8000", "在官网‘运单资料&签收图’,可以查看签收人信息", OrderInvoceStatus.COMPLETED),
    _130("130", "快件到达顺丰店/站", OrderInvoceStatus.TRANSIT),
    _123("123", "快件正在送往顺丰店/站", OrderInvoceStatus.TRANSIT),
    _607("607", "代理收件", OrderInvoceStatus.COLLECTED),
    _99("99", "应客户要求,正在转寄中", OrderInvoceStatus.REROUTING),
    _648("648", "快件已退回/转寄,新单号为xxx", OrderInvoceStatus.ERROR),

    EMPTY("", "", OrderInvoceStatus.ERROR)
    ;

    private final String code;
    private final String name;
    private final OrderInvoceStatus correspondingLogisticsStatus;

    public Boolean codeEq(String code) {
        return Objects.equals(this.code, code);
    }

    public static ExpressTraceOpCode of(String code) {
        for (ExpressTraceOpCode value : ExpressTraceOpCode.values()) {
            if (StringUtils.equals(value.code, code)) {
                return value;
            }
        }
        return EMPTY;
    }
}
